package ${package}.service.impl;

import ${package}.entity.${entityName};
import ${package}.dto.${entityName}QueryDTO;
import ${package}.mapper.${entityName}Mapper;
import ${package}.service.${entityName}Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements ${entityName}Service {

    private final ${entityName}Mapper mapper;

    @Override
    public IPage<${entityName}> page(${entityName}QueryDTO queryDTO) {
        return mapper.selectPage(new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize()), queryDTO);
    }

    @Override
    public ${entityName} getById(Long id) {
        return baseMapper.selectById(id);
    }

    @Override
    public void saveEntity(${entityName} entity) {
        baseMapper.insert(entity);
    }

    @Override
    public void updateEntity(${entityName} entity) {
        baseMapper.updateById(entity);
    }

    @Override
    public void deleteEntity(Long id) {
        baseMapper.deleteById(id);
    }
}